package com.moralesce.gt.model;

/**
 * The four categories in a deck of cards.
 * 
 * Each card bears one of four symbols showing which suit it belongs to. A deck
 * of cards has four suits: hearts, clubs, spades, and diamonds.
 * 
 * @author Brandon Grenier
 */
public enum Suit {

	HEART(43, "H"), SPADE(47, "S"), CLUB(53, "C"), DIAMOND(59, "D");

	private final String value;
	private final Integer id;

	private Suit(Integer id, String value) {
		this.id = id;
		this.value = value;
	}

	/**
	 * Returns the suit identifier.
	 * 
	 * @return The unique suit identifier.
	 */
	public Integer id() {
		return id;
	}

	/**
	 * Returns the suit value.
	 * 
	 * The value will be one of:<br/>
	 * H, S, C, D
	 * 
	 * @return The suit value.
	 */
	public String value() {
		return value;
	}

	/**
	 * Returns the suit for the given value.
	 * 
	 * @param value The value.
	 * 
	 * @return The suit for the given value.
	 * 
	 * @throws IllegalArgumentException if the specified value does not map to a
	 * suit.
	 */
	public static Suit forValue(String value) {
		for (Suit suit : Suit.values()) {
			if (suit.value().equalsIgnoreCase(value)) {
				return suit;
			}
		}
		throw new IllegalArgumentException(value + " is not a valid suit");
	}

}
